package org.example.system.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.example.system.common.result.Result;
import org.example.system.service.SystemInfoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Tag(name = "系统信息")
@RestController
@RequestMapping("/api/v1/system")
@RequiredArgsConstructor
@Slf4j
public class SystemInfoController {
    private final SystemInfoService systemInfoService;

    @Operation(summary = "获取系统信息")
    @GetMapping("/info")
    public Result<Map<String, Object>> getSystemInfo() {
        Map<String, Object> map = new HashMap<>();
        map.put("os", systemInfoService.getOsInfo());
        map.put("cpu", systemInfoService.getCpuInfo());
        map.put("memory", systemInfoService.getMemoryInfo());
        map.put("disk", systemInfoService.getDiskInfo());
        return Result.success(map);
    }
}
